﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using BO.Infrastructure.StaticData;
using BO.Infrastructure.Utils;

namespace GUI.Controls.Video
{
    public partial class ListVideo : System.Web.UI.UserControl
    {
        private const string ItemFormat ="<div class=\"video-item\">{3}<div class=\"video-info\"><div class=\"like-facebook\">{4}</div></div><h4><a href=\"{0}\" title=\"{2}\">{1}</a></h4></div>";
        private const string ButtonLikeFormat = "<iframe src=\"//www.facebook.com/plugins/like.php?locale=vi_VN&amp;href={0}&amp;send=false&amp;layout=button_count&amp;width=84&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=24&amp;appId=433277336731778\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:84px; height:21px;\" allowtransparency=\"true\"></iframe>";
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        public bool DataBind(DataTable dt)
        {
            if(dt!=null && dt.Rows.Count >0)
            {
                var sb = new StringBuilder();
                foreach (DataRow r in dt.Rows)
                {
                    var avatar = PresentationUtils.Photo.BuildPhoto(r[SqlConstants.Video.Avatar].ToString(),
                                                                    r[SqlConstants.Video.Name].ToString(),
                                                                    r[SqlConstants.Video.Url].ToString());
                    sb.AppendFormat(ItemFormat,
                                    r[SqlConstants.Video.Url],
                                    r[SqlConstants.Video.Name],
                                     r[SqlConstants.Video.EncodedName],
                                    avatar,
                                    string.Format(ButtonLikeFormat, PresentationUtils.UrlBuilder.BuildAbsoluteUrl(r[SqlConstants.Video.Url].ToString())));
                }
            }
            return false;
        }
    }
}